// Foundation.cpp: implementation of the CFoundation class.
//
//////////////////////////////////////////////////////////////////////


#include "Foundation.h"


#include "backbuffer.h"


CFoundation::CFoundation()
{

}

CFoundation::~CFoundation()
{

}

bool CFoundation::CheckPushPrecondition( const CCard &_card )
{
	
	if( false == CSlot::CheckPushPrecondition( _card ) ) return false;
	
	if( _card.IsFaceDown() ) return false;
	
	if( 0 == this->GetCardsStored() && CCard::Ace == _card.GetValue() )
		return true;
	else
	{
		/* Get Card from top and put it back */
		CCard tmp = this->PeekCard();
	
		if	( 
				tmp.GetSuit() == _card.GetSuit() &&
				( 
					( tmp.GetValue() == CCard::Ace && _card.GetValue() == CCard::Ace ) ||
					( tmp.GetValue() != CCard::Ace && 1 == tmp.CompareValue( _card ) )
				)
			)
			return true;
		else
			return false;
	}
}

void CFoundation::Draw(unsigned int _x, unsigned int _y, bool selected )
{
    throw "Draw not implemented!";
}

bool CFoundation::IncreaseSelection()
{
	if( cards_stored && cards_selected == 0 )
	{
		cards_selected = 1;
		return true;
	}
	return false;
}
